package com.zwz.service.impl;

import com.zwz.entity.SoftwareRegistry;
import com.zwz.mapper.SoftwareRegistryMapper;
import com.zwz.service.SoftwareRegistryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class SoftwareRegistryServiceImpl implements SoftwareRegistryService {

    @Autowired
    private SoftwareRegistryMapper mapper;

    @Override
    public void create(SoftwareRegistry entity,String enterpriseId) {
        if (!isRegistrationNumberUnique(entity.getRegistrationNumber())) {
            throw new IllegalArgumentException("登记编号已存在");
        }
        entity.setEnterpriseId(Integer.parseInt(enterpriseId));

        mapper.insert(entity);
    }


    @Override
    public void update(SoftwareRegistry entity) {

    }

    @Override
    public void delete(String  id) {

    }

    @Override
    public SoftwareRegistry getById(String  id) {
        return null;
    }

    @Override
    public boolean isRegistrationNumberUnique(String regNumber) {
        return mapper.selectByRegistrationNumber(regNumber).isEmpty();
    }

    @Override
    public List<SoftwareRegistry> getBySoftwareRegistry(String id) {
        return  mapper.searchByEnterPriseId(id);
    }

    @Override
    public List<SoftwareRegistry> searchByName(String name) {
        return mapper.searchByFullName(name);
    }

    // 其他方法实现...
}